package com.codinghero.example.longleg;

import java.io.File;
import java.util.Arrays;

public class GenerateImageSQL {
	
	public static void main(String[] args) {
		System.out.println("INSERT INTO pic(id, relative_path, name, des) VALUES");
		handleInFolder(Constant.ORIG.FOLDER_PATH);
	}

	private static void handleInFolder(String folderPath) {
		handleInFolder(folderPath, new File(folderPath).getName());
	}
	
	private static void handleInFolder(String folderPath, String pathPrefix) {
		File rootFolder = new File(folderPath);
		File[] files = rootFolder.listFiles();
		
		int id = Constant.GIRL_PIC.START_ID;
		for (File file : files) {
			if (file.isFile() && !file.getName().startsWith("Thumbs.db")) {
				String line = "(" + id++ + ", '/file/2013/" + pathPrefix + "/" + file.getName() + "', '', ''),";
				System.out.println(line);
			} else if (file.isDirectory() && !file.getName().startsWith("thumbs")) {
				handleInFolder(file.getPath(), pathPrefix + "/" + file.getName());
			}
		}
	}
}
